<?php

namespace App\Http\Requests\Api\Shop;

use Illuminate\Foundation\Http\FormRequest;
use App\Repos\ShopUserRepo;

class BaseRequest extends FormRequest
{
    public $shopUser;  

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {        
        $shopUser = ShopUserRepo::findByToken($this->token);
        if($shopUser && $shopUser->status!='-1') {          
            $this->shopUser    = $shopUser;
            return true;
        }        
        return false;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [];
    }

    public function messages()
    {
       return [];
    }

    

    public function pure()
    {
        $data = array_except($this->all(), ['token']);          
        return $data;
    }
}
